<?php
namespace Sys\Controller;
use Common\Controller\BaseController;


class CreditController extends BaseController{
    public function index2(){
        $nav = M('students')->select();
        $rule=M('points_rule')->select();
		//dump($rule);
        foreach($nav as $k=>$v){
            $nav[$k]['roleall']=$rule;
        }
        $this->assign('nav1',$nav);
		
        $this->assign('rule',$rule);

        $this->display();
    }

    //扣分
    public function deduct(){
        $b= I('post.point_rule_id');
		//dump($b);
        $score=M('points')->select($b);
        $a=M('points_rule')->field('sum(val)')->select($b);
        $_POST['score']=$a[0]["sum(val)"];
		 $_POST['points_time']=date('Y-m-d H:i:s',time());
        $_POST['ctime']=date('Y-m-d H:i:s',time());
		//dump($_POST);
        $a= M('points')->create();
        M('points')->add();
		
    }
	public function readCredit(){
		$res = M('view_points')-> select();
		$this-> assign('res',$res);
		$this-> display();
	}
	
	public function readDetail(){
		$sql = "
			SELECT rule_name,points_time FROM `pj_points` 
			INNER JOIN pj_points_rule ON pj_points_rule.point_rule_id = pj_points.point_rule_id
			WHERE pj_points.student_id = ".I('get.student_id')."
			";
		$M = new \Think\Model();
		$res = $M -> query($sql);
		$this-> assign('res',$res);
		$this->display();
	}



}